<template>
	<view><web-view :src="url"></web-view></view>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { isEmpty, formatUrlParam } from '@/assets/js/utils'

const url = ref('')
onLoad(options => {
	let param = JSON.parse(JSON.stringify(options))
	let baseUrl = ''
	if (!isEmpty(param)) {
		//设置标题
		if (param.title) uni.setNavigationBarTitle({ title: param.title })
		//如果跳转的是商家端H5页面，根据开发环境设置根路径
		if (param.isMerchantH5) {
			process.env.NODE_ENV === 'development' ? (baseUrl = 'https://dev.beautymz.com/merchant-h5/#') : (baseUrl = 'https://www.beautymz.com/merchant-h5/#')
			// https://dev.beautymz.com/merchant-h5/#
			// http://192.168.3.47:7017/#
			//携带token
			let token = uni.getStorageSync('uniToken')
			param.token = token

			//刷新token凭证
			let rfToken = uni.getStorageSync('uniRfToken')
			param.rfToken = rfToken
		}
		delete param.url
		delete param.title
		delete param.isMerchantH5
	}
	url.value = baseUrl + options.url + formatUrlParam(param)
})
</script>

<style></style>
